int to char ... date problem

R

Robin

I know that you would use cInt(n) to convert a string to an integer.
How do you convert an integer to a string?
I have a varChar field in a database that I am inserting a date field
(needs to be a char field).
The date is formatted like so:
y = year(now())
m = month(now())
d = day(now())
vNow = Y & "-" & M & "-" & D
To me this looks like it should come up with
vNow = 2004-6-25
But instead it is actually doing the math and coming up with
vNow = 1973
 
D

Dave Anderson

Robin said:
I have a varChar field in a database that I am inserting a date
field (needs to be a char field).

This makes no sense to me whatsoever. On one hand, it sounds as though you
want to convert a VARCHAR to a CHAR. That has nothing at all to do with ASP.
Beyond that, it is not clear if you are inserting a date (the abstract
notion of a date, that is) into a VARCHAR, or attempting to convert a
VARCHAR to a DATE.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
A

Aaron [SQL Server MVP]

I know that you would use cInt(n) to convert a string to an integer.
How do you convert an integer to a string?

CStr() ?
I have a varChar field in a database that I am inserting a date field

What? You're inserting a date value into a VARCHAR column? WHY?

Is this Access, SQL Server, FoxPro, MySQL, ...? What version?
But instead it is actually doing the math and coming up with
vNow = 1973

Can you show the actual code that causes this to happen?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top