473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

date value and timestamps

I know that if I have a full timestamp, and wrap the DateValue function
around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?
Jul 19 '05 #1
7 3194
AFAIK, no. Just like you can't do a formatdatetime and return "2:32 PM"
It's either "2:32:00 PM" or "14:32." I think that you'll have to manipulate
your date manually with some string manipulations or DatePart function to
return the date in the two digit year format. Just be aware that your
server may explode and your car will burst into flames when the clock
strikes midnight on the night of 12/31/2099.

Ray at work

"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
I know that if I have a full timestamp, and wrap the DateValue function
around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?

Jul 19 '05 #2
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
I know that if I have a full timestamp, and wrap the DateValue function
around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti
Jul 19 '05 #3
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
I know that if I have a full timestamp, and wrap the DateValue function
around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti

Jul 19 '05 #4
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
I know that if I have a full timestamp, and wrap the DateValue function around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


Interesting. I was not aware of that.
In that case, the "write your own" method:

Function shortDateString( oDate )
str = month( oDate ) & "/"
str = str & day( oDate ) & "/"
str = str & right( Year( oDate ), 2 )
shortDateString = str
End Function

Response.Write( shortDateString( Date ) )

Regards,
Peter
Jul 19 '05 #5
Thanks!
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
> I know that if I have a full timestamp, and wrap the DateValue

function > around it, it will give me mm/dd/yyyy. I can't seem to find a similar > function which would return a 2-digit year. Is there such a thing?

FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


Interesting. I was not aware of that.
In that case, the "write your own" method:

Function shortDateString( oDate )
str = month( oDate ) & "/"
str = str & day( oDate ) & "/"
str = str & right( Year( oDate ), 2 )
shortDateString = str
End Function

Response.Write( shortDateString( Date ) )

Regards,
Peter

Jul 19 '05 #6
Just construct it yourself:

sDate = Date
sMonth = DatePart("m", sDate )
sDay = DatePart("d", sDate )
If sMonth < 10 Then
sMonth = "0" & sMonth
End If
If sDay < 10 Then
sDay = "0" & sDay
End If
sFormattedDate = sMonth & "/" & sDay & "/" & Right(DatePart("yyyy", sDate),
2)

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
I know that if I have a full timestamp, and wrap the DateValue function around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


Jul 19 '05 #7
This will run faster:

Function shortDateString(oDate)
If IsDate(oDate) Then
Dim ar(4)
ar(0) = Month(oDate)
ar(1) = "/"
ar(2) = Day(oDate)
ar(3) = "/"
ar(4) = Right(Year(oDate),2)
shortDateString = Join(ar,"")
End If
End Function

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
1
by: Jim | last post by:
Can someone tell me how the following date and time is created to the Hex value (also shown below)? Tuesday, July 08, 2003 10:56:38 AM hex:00,90,a6,7b,66,45,c3,01 I need to be able to...
2
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples...
2
by: jrthor2 | last post by:
I have a shell script that I am using the db2 load command to populate my table with. I have a problem with the dates though. In my file that I am populating the table with, I have 3 date fields...
3
by: dave | last post by:
I need to compute an expiration date based on the number of hours, days, or months purchased. The expiration date needs to be expressed in minutes something like '1260481600'. How can I get the...
3
by: mantrid | last post by:
Hello I have date and time in my mysql table in the form 2007-05-03 00:00:00 which I have dispayed on my webpage using echo $selldatetime I want to know how I can display it in the form...
8
by: Rob Wilkerson | last post by:
Surprisingly (at least to me), there doesn't seem to be a built-in function to validate a date value (like, say, is_date()). Given that, is there a best practice for determining whether a value is...
2
by: Kerryn | last post by:
Hi all new to this site so looking for some help. I am working in Access 2002, using a select query. I am trying to use a date range parameter to allow the users to end the start date and end...
3
by: Cron | last post by:
Hi I'm trying to Dcount *unique* records by comparing a date/time field. I say *unique* because the field contains a date/time but I need to ignore the timestamp and work off the date only. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.