473,698 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3214
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********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"middletree " <mi********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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******** ******@tk2msftn gp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"middletree " <mi********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:eZ******** ******@tk2msftn gp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"middletree " <mi********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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******** ******@tk2msftn gp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"middletree " <mi********@hto mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP11.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(oDat e),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
9292
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 three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
7
3933
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? If the timestamps measure visits to a web site, how to easily say there were 45 visits on January 4th? The first idea that occurs to me is to put them all in an array and then loop through the array and use date() on each, one at a time,...
1
10635
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 create the hex value for any date, but am not sure how to break it down. Serail Parts?
2
4351
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 showing what I am experiencing. The last own shows how converting timestamps to dates and then ordering doesn't give you the order you want. Maybe you should just order by the timestamp to begin with. However Date does not understand infinity at all.
2
4904
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 that get are in the format yyyy-mm-dd. The table has these columns set as timestamps. When my shell script runs, I get the following error: SQL3407N The beginning-ending location pair for inserting into column "35" is not valid for a...
3
3439
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 current date and time expressed in minutes? Once I have this number I can add the number of minutes purchased to the current date/time to get the expiration date.
3
1622
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 03-05-2007 Thanks
8
1949
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 a valid date/time? The values I need to test will likely be unix timestamp values and I need to be able to distinguish them as date/time values from other integer/numeric values. What I'm trying to do is use reflection to iterate over the...
2
2123
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 date i.e 1/1/08 and 31/1/08, the field name is Transaction Date and some dates have timestamps and some dont. Parameter >= And <= When entering the last date the query, if the transaction date record has a time stamp of 31/1/08 10:23 this is not...
3
5929
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 think the code below should work to count unique values in a normal text field but the date/time is causing a lot of problems because it's reading the timestamps to be different despite the "medium date" formatting. DCount("", "attendance",...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.