Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Convert string into date format

Author  Topic 

lsy
Yak Posting Veteran

57 Posts

Posted - 2006-07-10 : 21:07:13
How can i convert a string into format of date??
as i know there have TO_DATE in sql what about in access??

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-07-10 : 22:48:12
You need to convert it to a date first (using CDate), then Format to convert it back to a string.
Go to Top of Page

lsy
Yak Posting Veteran

57 Posts

Posted - 2006-07-10 : 23:04:23
How to use this CDate? i never use before!!
Go to Top of Page

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-07-10 : 23:25:22
Depends on if you want to use it in a query or in VBA.

The basics are:
yourDate = CDate("20-May-1975")

For more info, consult your online help (F1)
Go to Top of Page

lsy
Yak Posting Veteran

57 Posts

Posted - 2006-07-11 : 00:29:02
My current date column in database is with text format... how can i convert it into date with using CDate and display as work week in sql statement?
Go to Top of Page

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-07-11 : 01:12:05
SELECT Format(CDate(yourDateField), "dd-mmm-yyyy")
FROM yourTable

I don't know what you mean by 'work week', but you can change the format of the date by playing around with the string you pass into the Format function (i.e. "dd-mmm-yyyy")
Go to Top of Page

shaili
Starting Member

1 Post

Posted - 2011-08-08 : 07:00:11
Please help me with a query!
I have craeted a stored procedure and decalred a variable @mydate.I gave set the value of this variable as "January".Now i want to add one month to this value.Say if i assigned May to this procedure it should return june.However there are no date or year passed.
Go to Top of Page

3magic
Starting Member

14 Posts

Posted - 2011-08-09 : 00:49:55
CDate"27-june-1985")
by
[url=http://www.3magicbeans.com]Website Development Denver
[/url]
Go to Top of Page
   

- Advertisement -