Date Problem

D

DS

I have two fields the first one holds the number of the month.
Such as 01,02 etc.... This is TxtMonth
The second one holds the date
Such as 2001,2002 etc...This is TxtYear

From another form I pick the values and put them into an unbound field
such as...Forms!Form1!TxtExpDate = Me.TxtMonth & " / " & Me.TxtYear

Resulting in TxtExpDate 01 / 2002

After which I do SQL UPDATE to insert the value into a field in a table.
The problem is I'm not getting the same info. How can I insert this
value into the table so that it ends up the way it should?
Thanks
DS
 
J

Jeff L

After which I do SQL UPDATE to insert the value into a field in a table.

Are you inserting or updating? They are two different things.
 
D

DS

Jeff said:
Are you inserting or updating? They are two different things.
Your right. I'm probably more interested in combining the two fields
TxtMonth and TxtYear into a legitamate date field. If you would guide
me through this I would be very happy and appreciative!
Thanks
DS
 
D

Douglas J. Steele

DS said:
Jeff L wrote:
Your right. I'm probably more interested in combining the two fields
TxtMonth and TxtYear into a legitamate date field. If you would guide me
through this I would be very happy and appreciative!

You can't. Month and Year aren't sufficient to be a date: you need Day as
well. Internally, Dates are stored as 8 byte floating point numbers, where
the integer portion represents the date as the number of days relative to 30
Dec, 1899, and the decimal portion represents the time as a fraction of a
day.

If you want to pick an arbitrary day of the month to use, you can use
something like:

Forms!Form1!TxtExpDate = DateSerial(Me.TxtYear, Me.TxtMonth, 1)
 
D

DS

Douglas said:
You can't. Month and Year aren't sufficient to be a date: you need Day as
well. Internally, Dates are stored as 8 byte floating point numbers, where
the integer portion represents the date as the number of days relative to 30
Dec, 1899, and the decimal portion represents the time as a fraction of a
day.

If you want to pick an arbitrary day of the month to use, you can use
something like:

Forms!Form1!TxtExpDate = DateSerial(Me.TxtYear, Me.TxtMonth, 1)
Great Douglas! That works!
Thanks
DS
 

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

Similar Threads

Use of DCount 27
Open a form using Openargs 3
Update with SQL 3
Filter based on date range and a field value 6
Dcount returning no results!!! 0
update time value issue 7
Problem with SQL 5
Stumped By Dates 4

Top