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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Formating - Newbie

Status
Not open for further replies.

sibleytr

Technical User
Jan 27, 2005
21
US

Whenever I update a table I would like a record set that will fill in the current Date(). That's the easy part.

I want to take a given Date() = 2/3/2005 and add leading "0"'s well as split the Date into two fields.

So the date #2/3/2005# result would be:

02-03 2005

Any ideas?

 
Don't worry about the way it is stored in the database itself... Only worry about the way it is displayed later when you take it OUT of the database to use it.

There is a VB function called Format() that will allow you to display the date as you wish.
 
For this 02-03 from this 2/3/2005 the following:

Format(Month(Date),"00") & Format(Day(Date),"00")

For this 2005 from 2/3/2005 the following:

Year(Date)

John Borges
 
DateMonth = Mid(Format(DBDate, "DD-MM-YYYY"), 1, 5)
DateYear = Mid(Format(DBDate, "DD-MM-YYYY"), 6, 4)

????

Is this a faster and easier or slower and more cumbersome method?



jgjge3.gif
[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Format(myDate,"dd-mm") will give the day and month with a hyphen separator

Format(myDate,"yy") will give the year in a 2-digit format

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top