INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Format text date to 1st day of month...

Format text date to 1st day of month...

(OP)
I have a table with records that hold a "text date" that is formatted like:
Mar-2015
Apr-2015
Feb-2015
Dec-2014

I need this field reformatted with a new field to show the value like:
3/1/2015
4/1/2015
2/1/2015
12/1/2014

Any suggestions or examples..?

RE: Format text date to 1st day of month...

It is better to store a real date value, then you can use the format function to display it anyways you want. So if you would have stored 1/1/2015 you can display it anywhere as Jan-2015. More importantly you then can do date calculations in your database if needed.

So I would convert it to a real date

Public Function TextToDate(strDate) as date
TextToDate = cdate("1-" & strDate)
end function

You can use this function in a query as

Select yourDate, TextToDate([yourDate]) as RealDate,...

The cdate function is real powerful. It can convert most strings or number that remotely looks like a date into a date.

RE: Format text date to 1st day of month...

The cdate function is more powerful than I thought
You do not even have to first coerce the string into 1-Mon-2015 format. Simply
cdate("Dec-2015") produces the date 12/1/2015
so in a query
Select yourDate, cdate([yourDate]) as RealDate

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close