Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date information 1

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
Sorry to put forward what is probably a very simple question but here goes......

I want to store a date mmm/yyyy. That is all I want stored, but I would like it stored as a date. Is there any possible way to do this?

I am admittedly just starting my reading in the books online in regards to dates, so the easy answer is probably in there for me, but if anyone could save me a bit of time I would really appreciate it.
 
Crystalized, you cannot control how SQLS stores the dates; you can only affect how it returns date values. Therefore, in your SELECT statements or views, you could use the DatePart function and build a character-type column that is based on the underlying date but is formatted any way you wish.
 
SELECT DATEPART(m, 0), DATEPART(d, 0), DATEPART(yy, 0)

Here is the result set:
----- ------ ------

1 1 1900

The 0 is interpreted as 1900 so,
in your case what about:

Select Datepart (mm,getdate()),Datepart(year,getdate()) as date.

In this case your result would be:
date
----------- -----------
8 2000

Of course you will have to format this to your specifications.

Hope this is what you are looking for.


 
Thanks a bunch to both of you, especially since the replies were so quick, I really appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top