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

Date formatted as text

Status
Not open for further replies.

benderulz

IS-IT--Management
Joined
Nov 2, 2010
Messages
43
Location
US
Is there a way to format Now()-1 as text used in a query criteria?

example 2011-10-26 07:30:00 would show as 20111026073000
 
Now()-1 is a day ago.

So if now() is:
10/26/2011 2:11:40 PM

and now()-1 is:
10/25/2011 2:11:40 PM

then I would think now()-1 as a big text string is:
SELECT year(now()-1)&month(now()-1)&day(now()-1)&hour(now()-1)&minute(now()-1)&second(now()-1)

or:
20111025141140

 
Although why you would want to do that and make a date harder to work with I don't know.
 


Code:
format(Now()-1,"yyyymmddhhnnss")


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

A little easier:
Code:
Select Format(Now()-1,"yyyymmddhhmmss") ...

 

Dangit Skip, you did it again... beat me by seconds!
 

...and I had a typo. "...hhmmss" should be "...hhnnss" as Skip shows.
 
@BigRed1212 Unfortunately, I'm working with someone else's database that formatted their dates that way. Caused me nothing but problems.

Thanks everyone for your help!
 



Next to useless!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top