PC Review


Reply
Thread Tools Rate Thread

Date and time text string to date variable

 
 
John Marshall, MVP
Guest
Posts: n/a
 
      28th Jan 2004
Now that I have the YMD text string to date conversion working, how do I
convert two text strings, one "YYYYMMDD" and the second "HH:MM" to a date
variable?

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm


 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      28th Jan 2004
John - I haven't followed your earlier threads, but there are two ways you
can convert a "date string" to a "date variable":

(1) If you put the date string into a recognizable format (say,
"mm/dd/yyyy"), you can use the DateValue function to convert it to a date
value:
MyDate = DateValue(Right("YYYYMMDD",2) & "/" & Mid("YYYYMMDD",5,2) &
"/" & Left("YYYYMMDD",4))

(2) You can use the DateSerial function to convert to a date:
MyDate = DateSerial(CInt(Left("YYYYMMDD",4)),
CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2)))


--
Ken Snell
<MS ACCESS MVP>

"John Marshall, MVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Now that I have the YMD text string to date conversion working, how do I
> convert two text strings, one "YYYYMMDD" and the second "HH:MM" to a date
> variable?
>
> John... Visio MVP
>
> Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> Need VBA examples? http://www.mvps.org/visio/VBA.htm
> Common Visio Questions http://www.mvps.org/visio/common_questions.htm
>
>



 
Reply With Quote
 
 
 
 
John Marshall, MVP
Guest
Posts: n/a
 
      28th Jan 2004
Thanks Ken, but the date part works fine, the problem I have is creating a
date variable from two text strings (one has "YYYYMMDD" and the other has
"HH:MM"). From what I have discovered is that I need to load the date string
into a date variable and then create a new string in the format as "Jan 1,
2004" and then combine that with the "HH:MM" string. This is seems like a
lot of work for something that should be easier.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
"Ken Snell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> John - I haven't followed your earlier threads, but there are two ways you
> can convert a "date string" to a "date variable":
>
> (1) If you put the date string into a recognizable format (say,
> "mm/dd/yyyy"), you can use the DateValue function to convert it to a date
> value:
> MyDate = DateValue(Right("YYYYMMDD",2) & "/" & Mid("YYYYMMDD",5,2)

&
> "/" & Left("YYYYMMDD",4))
>
> (2) You can use the DateSerial function to convert to a date:
> MyDate = DateSerial(CInt(Left("YYYYMMDD",4)),
> CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2)))
>
>
> --
> Ken Snell
> <MS ACCESS MVP>
>
> "John Marshall, MVP" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Now that I have the YMD text string to date conversion working, how do I
> > convert two text strings, one "YYYYMMDD" and the second "HH:MM" to a

date
> > variable?
> >
> > John... Visio MVP
> >
> > Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> > Need VBA examples? http://www.mvps.org/visio/VBA.htm
> > Common Visio Questions http://www.mvps.org/visio/common_questions.htm
> >
> >

>
>



 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      28th Jan 2004
Sorry...too early in the morning..missed the time feature.

You can use the TimeSerial function to get the time into a fractional
number, then add it to the DateSerial value.

MyDateAndTime = DateSerial(CInt(Left("YYYYMMDD",4)),
CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2))) +
TimeSerial(CInt(Left("HH:MM",2)), CInt(Right("HH:MM",2)), 0)

--
Ken Snell
<MS ACCESS MVP>

"John Marshall, MVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Ken, but the date part works fine, the problem I have is creating a
> date variable from two text strings (one has "YYYYMMDD" and the other has
> "HH:MM"). From what I have discovered is that I need to load the date

string
> into a date variable and then create a new string in the format as "Jan 1,
> 2004" and then combine that with the "HH:MM" string. This is seems like a
> lot of work for something that should be easier.
>
> John... Visio MVP
>
> Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> Need VBA examples? http://www.mvps.org/visio/VBA.htm
> Common Visio Questions http://www.mvps.org/visio/common_questions.htm
> "Ken Snell" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > John - I haven't followed your earlier threads, but there are two ways

you
> > can convert a "date string" to a "date variable":
> >
> > (1) If you put the date string into a recognizable format (say,
> > "mm/dd/yyyy"), you can use the DateValue function to convert it to a

date
> > value:
> > MyDate = DateValue(Right("YYYYMMDD",2) & "/" &

Mid("YYYYMMDD",5,2)
> &
> > "/" & Left("YYYYMMDD",4))
> >
> > (2) You can use the DateSerial function to convert to a date:
> > MyDate = DateSerial(CInt(Left("YYYYMMDD",4)),
> > CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2)))
> >
> >
> > --
> > Ken Snell
> > <MS ACCESS MVP>
> >
> > "John Marshall, MVP" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Now that I have the YMD text string to date conversion working, how do

I
> > > convert two text strings, one "YYYYMMDD" and the second "HH:MM" to a

> date
> > > variable?
> > >
> > > John... Visio MVP
> > >
> > > Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> > > Need VBA examples? http://www.mvps.org/visio/VBA.htm
> > > Common Visio Questions http://www.mvps.org/visio/common_questions.htm
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
John Marshall, MVP
Guest
Posts: n/a
 
      28th Jan 2004
Duh! If you need to add time to date you ADD time to date.

Thanks Ken

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
"Ken Snell" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Sorry...too early in the morning..missed the time feature.
>
> You can use the TimeSerial function to get the time into a fractional
> number, then add it to the DateSerial value.
>
> MyDateAndTime = DateSerial(CInt(Left("YYYYMMDD",4)),
> CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2))) +
> TimeSerial(CInt(Left("HH:MM",2)), CInt(Right("HH:MM",2)), 0)
>
> --
> Ken Snell
> <MS ACCESS MVP>
>
> "John Marshall, MVP" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks Ken, but the date part works fine, the problem I have is creating

a
> > date variable from two text strings (one has "YYYYMMDD" and the other

has
> > "HH:MM"). From what I have discovered is that I need to load the date

> string
> > into a date variable and then create a new string in the format as "Jan

1,
> > 2004" and then combine that with the "HH:MM" string. This is seems like

a
> > lot of work for something that should be easier.
> >
> > John... Visio MVP
> >
> > Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> > Need VBA examples? http://www.mvps.org/visio/VBA.htm
> > Common Visio Questions http://www.mvps.org/visio/common_questions.htm
> > "Ken Snell" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > John - I haven't followed your earlier threads, but there are two ways

> you
> > > can convert a "date string" to a "date variable":
> > >
> > > (1) If you put the date string into a recognizable format (say,
> > > "mm/dd/yyyy"), you can use the DateValue function to convert it to a

> date
> > > value:
> > > MyDate = DateValue(Right("YYYYMMDD",2) & "/" &

> Mid("YYYYMMDD",5,2)
> > &
> > > "/" & Left("YYYYMMDD",4))
> > >
> > > (2) You can use the DateSerial function to convert to a date:
> > > MyDate = DateSerial(CInt(Left("YYYYMMDD",4)),
> > > CInt(Mid("YYYYMMDD",5,2)), CInt(Right("YYYYMMDD",2)))
> > >
> > >
> > > --
> > > Ken Snell
> > > <MS ACCESS MVP>
> > >
> > > "John Marshall, MVP" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > Now that I have the YMD text string to date conversion working, how

do
> I
> > > > convert two text strings, one "YYYYMMDD" and the second "HH:MM" to a

> > date
> > > > variable?
> > > >
> > > > John... Visio MVP
> > > >
> > > > Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> > > > Need VBA examples? http://www.mvps.org/visio/VBA.htm
> > > > Common Visio Questions

http://www.mvps.org/visio/common_questions.htm
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining whether a string is a date, time, or date and time Nathan Sokalski Microsoft VB .NET 5 27th Mar 2008 06:42 AM
Trying To Append String Variable To Another String Variable =?Utf-8?B?Sm9lIEsu?= Microsoft Excel Programming 3 6th Oct 2007 02:11 AM
SQL String variable within another String Variable =?Utf-8?B?U3RldmUgUw==?= Microsoft Access Form Coding 1 17th Feb 2007 11:45 PM
select offset (variable ,1) to offset(variable ,variable) Buffyslay Microsoft Excel Programming 1 15th Nov 2006 12:45 PM
Function like "Generic::List<String^>^ buildList(String^ inParm)" and avoiding warning C4172: returning address of local variable or temporary rsa_net_newbie Microsoft VC .NET 4 19th Oct 2006 05:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:29 AM.