Convert time field to text

  • Thread starter Thread starter vseale
  • Start date Start date
V

vseale

I have an access 2000 table I want to append into a linked
SQL table. The time field needs to be converted to text
during the append. Any hints are greatly appreciated.
Thanks in advanced for your help.
 
strTime= Format ("hh:mm", TimeField)

The format string given is an example - the possible values are given
in Help for the Fomat () function.

I have an access 2000 table I want to append into a linked
SQL table. The time field needs to be converted to text
during the append. Any hints are greatly appreciated.
Thanks in advanced for your help.


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
I saw that in Help and interpreted to mean it converted
text to Time. I need to convert Time to Text. I'm
appending recordsets to a SQL table, so I was anticipating
that there was some SQL-like command that I missed,
something like - DoCmd.RunSQL "INSERT INTO tblIMC_Hold (
TICKET, COMPLETE, convert([TimeCreat],DateTime(),Text
(50)), TASK)";.
 
You interpreted it incorrectly! Format () always returns a text
string, as should have been clear from my example. The second argument
is the DateTime variable to be converted; the first argument is a text
string indicating the format to be used in the conversion.

I saw that in Help and interpreted to mean it converted
text to Time. I need to convert Time to Text. I'm
appending recordsets to a SQL table, so I was anticipating
that there was some SQL-like command that I missed,
something like - DoCmd.RunSQL "INSERT INTO tblIMC_Hold (
TICKET, COMPLETE, convert([TimeCreat],DateTime(),Text
(50)), TASK)";.
-----Original Message-----
strTime= Format ("hh:mm", TimeField)

The format string given is an example - the possible values are given
in Help for the Fomat () function.




Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
.


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
You interpreted it incorrectly! Format () always returns a text
string, as should have been clear from my example. The second argument
is the DateTime variable to be converted; the first argument is a text
string indicating the format to be used in the conversion.

I think you have that backwards, Peter; the first argument is the
value to be formatted, and the second is the format string. That is,

Format([datetimefield], "hhnn")

will convert the current time (as I post this, though of course
'tempus fugit') to a text string "1448".


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
You're right, of course - I checked twice and still got it backwards!

You interpreted it incorrectly! Format () always returns a text
string, as should have been clear from my example. The second argument
is the DateTime variable to be converted; the first argument is a text
string indicating the format to be used in the conversion.

I think you have that backwards, Peter; the first argument is the
value to be formatted, and the second is the format string. That is,

Format([datetimefield], "hhnn")

will convert the current time (as I post this, though of course
'tempus fugit') to a text string "1448".


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top