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

If left(DateTime,10) = Date Please help me

Status
Not open for further replies.

FlatHead

Programmer
Oct 13, 2000
50
0
0
GB
Hi everybody

All i want to do is to read from a table a datetime field which has the following format:

DateTime

28/12/2000 07:55:00

All i want to do is to select only the Date Information and
compare it to the todays date.
If they are equal then i want to print a small image.

Im using this:
If left(DateTime,10) = Date then
Response.Write &quot;<td><img SRC=../images/tick.gif></td>&quot;
else
Response.Write &quot;<td><img SRC=../images/cross.gif></td>&quot;
end if
oRecord.Close

If i Response.Write the: <left(DateTime,10)> returns me the date which i want to use.

But when im comparing this with DATE is not working properly.
I don't have a clue y.
Anybody can help me please:)))))))))))))))))))))))))
 
Isn't working properly? More details, please. What sort of error(s) are you getting?
 
OK im having:
(If left(DateTime,10) = Date then)
If i do:
Response.Write &quot;DateTime: &quot; & (left(DateTime,10)) & &quot;&quot;
I m getting
DateTime: 12/04/2001
Which is Excactly the Same with the todays date

But unfortunatelly when i want to print something like an image when
left(DateTime,10) = Date
This igonores the first bit i mean the equals and goes directly to my else statement where the two are not equal..

For the following...

If left(DateTime,10) = Date then
Response.Write &quot;<td><img SRC=../images/tick.gif></td>&quot;
else
Response.Write &quot;<td><img SRC=../images/cross.gif></td>&quot;
end if
oRecord.Close

Even if the date is eual to the (left(DateTime,10)) this is not working and jumps to the next line and prints the cross.gif.

I hope this will help


In other worlds
 
VBScript hrm ... how 'bout the FormatDateTime function?

e.g. if FormatDateTime(dtDateTime, 1) = FormatDateTime(Now, 1) codestorm
 
looks like you are comparing text to date.
This won't do.
Need to convert text to date before comparsion.

If left(DateTime,10) = Date then

above should be...

If cdate(left(DateTime,10)) = Date then

redwine0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top