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

Date issue

Status
Not open for further replies.

janise

Technical User
May 25, 2003
161
US
Urgent help needed.

We have a date field on our database called
date_submitted.

I want this date to return only
month, day and year, no day, no time.
In other words, I want:
June 29, 2004

So far, the one I am using is returning:

Day, month and year like:

Tuesday, June 29 2004.

Can I get urgent help in fixing this, please:

Code:
     varDate = CDate(rs("Date_submitted"))
     varDate = FormatDateTime(varDate, 1)
 
if you dont mind doing string manipulations then try this:

varDate = Right(Instr(FormatDateTime(varDate, 1),","))

-VJ
 
Hi,
This is what I got when I tried using your code:

Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'Right'
 
oops sorry...try this:

varDate = Right(varDate, Instr(FormatDateTime(varDate, 1),","))
 
hi Amorous, and thanks for the help but this what I am getting when I ran your code:

/29/2004
 
Code:
varMonth=MonthName(varDate)
varDay=Day(varDate)
varYear=Year(varDate)
DisplayDate=varMonth & " " & varDay & ", " & varYear

That should do the trick.

--
PG
 
You said your code was returning :

Tuesday, June 29 2004

then how come your result is /29/2004 ??

-VJ
 
FormatDateTime(datevar,1) only returns the date. If you have the day of week in your output it must be coming from somewhere else.

I was going to google to get you the official definition, but I figure I'll leave it for someone else.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
hi PG!

I ran the code and got this:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'MonthName'

BTW: Thanks a lot!
 
Cdate(InputDate) and Tarwn's method is your best, and most pliable option

[thumbsup2]DreX
aKa - Robert
 
amorous and Tarwn, I didn't see your code before my last post.

First amorous.
If I run this code:

varDate = CDate(rs("Date_submitted"))
varDate = FormatDateTime(varDate, 1)

I get Tuesday, June 29, 2004.

If you don't believe me, do a response.write and you will see.

Ok, I see what was happening!
Date is being submitted as Number/day/yyyy = 6/29/2004.
I think that was the problem.
But I don't understand how date submitted could be 6/29/2004 when I coded it like this:

dim todaysDate
todaysDate=date()

insert into table (date_submitted)
values (" '" & todaysDate & "'" )
Shouldn't this give me MonthName/day/yyyy ?
 
PG,
Your code worked perfectly.

I am sure Tarwn's recommendation would work if the date is submitted as Monthname/day/yyyy which was what I was using before I ran into problem

I will stick with PG's for now.

I appreciate all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top