423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

convert to date format

P: n/a
How can I convert this pubLatest to a date with format "m/d/yyyy"?

Dim pubLatest As New Date
pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
--
_____
DC G
Nov 18 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
"DC Gringo" <dc******@visiontechnology.net> wrote in news:e2T7mLQlEHA.3968
@TK2MSFTNGP11.phx.gbl:
How can I convert this pubLatest to a date with format "m/d/yyyy"?


Use the function FormatDateTime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2

P: n/a
Thank you...

The only thing that did was set my time to 12:00

pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

______
DC G

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"DC Gringo" <dc******@visiontechnology.net> wrote in news:e2T7mLQlEHA.3968
@TK2MSFTNGP11.phx.gbl:
How can I convert this pubLatest to a date with format "m/d/yyyy"?


Use the function FormatDateTime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #3

P: n/a
"DC Gringo" <dc******@visiontechnology.net> wrote in news:OgmGIYQlEHA.1904
@TK2MSFTNGP09.phx.gbl:
Thank you...

The only thing that did was set my time to 12:00


I posted the wrong function...

Give Format a try.

http://msdn.microsoft.com/library/de...l=/library/en-
us/vblr7/html/vafctformatdatetime.asp


--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #4

P: n/a
What variable type is pubLatest? Turn Option Strict On!!!

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
Thank you...

The only thing that did was set my time to 12:00

pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

______
DC G

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"DC Gringo" <dc******@visiontechnology.net> wrote in
news:e2T7mLQlEHA.3968
@TK2MSFTNGP11.phx.gbl:
> How can I convert this pubLatest to a date with format "m/d/yyyy"?
>


Use the function FormatDateTime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #5

P: n/a
Dim s As String = FormatDateTime(DateTime.Now, DateFormat.ShortDate)

s = "9/7/2004"

works for me

Greg

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"DC Gringo" <dc******@visiontechnology.net> wrote in news:OgmGIYQlEHA.1904
@TK2MSFTNGP09.phx.gbl:
Thank you...

The only thing that did was set my time to 12:00


I posted the wrong function...

Give Format a try.

http://msdn.microsoft.com/library/de...l=/library/en-
us/vblr7/html/vafctformatdatetime.asp


--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #6

P: n/a
Still no luck...neithr of these work...they both return times...

Could it be because of my declaration?

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

"Brian" <ja*****@amc.com> wrote in message
news:38**********************************@microsof t.com...
Did you try pubLatest.ToShortDateString()?

Brian

"DC Gringo" wrote:
Thank you...

The only thing that did was set my time to 12:00

pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

______
DC G

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"DC Gringo" <dc******@visiontechnology.net> wrote in news:e2T7mLQlEHA.3968 @TK2MSFTNGP11.phx.gbl:

> How can I convert this pubLatest to a date with format "m/d/yyyy"?
>

Use the function FormatDateTime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #7

P: n/a
Place Option Strict On at the top of your file!!!

When you do you will see this will not compile:

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Without Option Strict you are just playing a casting game. Casting a
sqldate to a string back to a date

If you want to format it for display, then stuff the result of either method
into a STRING, not a date variable.

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
Still no luck...neithr of these work...they both return times...

Could it be because of my declaration?

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

"Brian" <ja*****@amc.com> wrote in message
news:38**********************************@microsof t.com...
Did you try pubLatest.ToShortDateString()?

Brian

"DC Gringo" wrote:
> Thank you...
>
> The only thing that did was set my time to 12:00
>
> pubLatest =
> FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
> DateFormat.ShortDate)
>
> ______
> DC G
>
> "Lucas Tam" <RE********@rogers.com> wrote in message
> news:Xn***************************@140.99.99.130.. .
> > "DC Gringo" <dc******@visiontechnology.net> wrote in news:e2T7mLQlEHA.3968 > > @TK2MSFTNGP11.phx.gbl:
> >
> > > How can I convert this pubLatest to a date with format "m/d/yyyy"?
> > >
> >
> > Use the function FormatDateTime
> >
> > --
> > Lucas Tam (RE********@rogers.com)
> > Please delete "REMOVE" from the e-mail address when replying.
> > http://members.ebay.com/aboutme/coolspot18/
>
>
>


Nov 18 '05 #8

P: n/a
Thanks, Greg, we're getting there...still have some compile errors, though.

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

Give me error: 'ToShortDateString' is not a member of 'String'.
-- and --

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."

_____
DC G

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
Place Option Strict On at the top of your file!!!

When you do you will see this will not compile:

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Without Option Strict you are just playing a casting game. Casting a
sqldate to a string back to a date

If you want to format it for display, then stuff the result of either method into a STRING, not a date variable.

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
Still no luck...neithr of these work...they both return times...

Could it be because of my declaration?

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

"Brian" <ja*****@amc.com> wrote in message
news:38**********************************@microsof t.com...
Did you try pubLatest.ToShortDateString()?

Brian

"DC Gringo" wrote:

> Thank you...
>
> The only thing that did was set my time to 12:00
>
> pubLatest =
> FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
> DateFormat.ShortDate)
>
> ______
> DC G
>
> "Lucas Tam" <RE********@rogers.com> wrote in message
> news:Xn***************************@140.99.99.130.. .
> > "DC Gringo" <dc******@visiontechnology.net> wrote in

news:e2T7mLQlEHA.3968
> > @TK2MSFTNGP11.phx.gbl:
> >
> > > How can I convert this pubLatest to a date with format "m/d/yyyy"? > > >
> >
> > Use the function FormatDateTime
> >
> > --
> > Lucas Tam (RE********@rogers.com)
> > Please delete "REMOVE" from the e-mail address when replying.
> > http://members.ebay.com/aboutme/coolspot18/
>
>
>



Nov 18 '05 #9

P: n/a
<sigh> :^)

You turn on Option Strict to discover where you are making implicit castings
at. And that is exaclty what it did.
Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."
Like I said, you are trying to shove a string (the result of either function
is a string, not a date) into a date variable. Hence "Option Strict On
disallows implicit conversions from 'System.Object' to 'Date'."

Don't do that!

If you want to display a date variable (pubLatest), then you must convert it
to a string (using either method). Both of the functions return a STRING,
not a DATE. So you cannot store it back into a DATE variable. (Well, you
can with Option strict off, but it is just casting it back to a DATE
implicitly.)

Make a new variable (say "s")

Public s As String
s = FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Now use "s" to display it your date variable as a formatted string.

Debug.Writeline(s)

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ux*************@TK2MSFTNGP11.phx.gbl... Thanks, Greg, we're getting there...still have some compile errors,
though.

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

Give me error: 'ToShortDateString' is not a member of 'String'.
-- and --

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."

_____
DC G

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
Place Option Strict On at the top of your file!!!

When you do you will see this will not compile:

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Without Option Strict you are just playing a casting game. Casting a
sqldate to a string back to a date

If you want to format it for display, then stuff the result of either

method
into a STRING, not a date variable.

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
> Still no luck...neithr of these work...they both return times...
>
> Could it be because of my declaration?
>
> Public pubLatest As Date
> pubLatest =
> FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
> DateFormat.ShortDate)
>
> pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
> pubLatest.ToShortDateString()
>
>
>
> "Brian" <ja*****@amc.com> wrote in message
> news:38**********************************@microsof t.com...
>> Did you try pubLatest.ToShortDateString()?
>>
>> Brian
>>
>> "DC Gringo" wrote:
>>
>> > Thank you...
>> >
>> > The only thing that did was set my time to 12:00
>> >
>> > pubLatest =
>> > FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
>> > DateFormat.ShortDate)
>> >
>> > ______
>> > DC G
>> >
>> > "Lucas Tam" <RE********@rogers.com> wrote in message
>> > news:Xn***************************@140.99.99.130.. .
>> > > "DC Gringo" <dc******@visiontechnology.net> wrote in
> news:e2T7mLQlEHA.3968
>> > > @TK2MSFTNGP11.phx.gbl:
>> > >
>> > > > How can I convert this pubLatest to a date with format "m/d/yyyy"? >> > > >
>> > >
>> > > Use the function FormatDateTime
>> > >
>> > > --
>> > > Lucas Tam (RE********@rogers.com)
>> > > Please delete "REMOVE" from the e-mail address when replying.
>> > > http://members.ebay.com/aboutme/coolspot18/
>> >
>> >
>> >
>
>



Nov 18 '05 #10

P: n/a

Dim pubLatest As String

pubLatest =
CDate(Me.SqlSelectCommand1.Parameters("@pubLatest" ).Value).ToShortDateString()
Mythran
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ux*************@TK2MSFTNGP11.phx.gbl...
Thanks, Greg, we're getting there...still have some compile errors, though.

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

Give me error: 'ToShortDateString' is not a member of 'String'.
-- and --

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."

Nov 18 '05 #11

P: n/a
Greg,

You are the man...it worked!

Sorry for the density upstairs over here...

_____
Glenn

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
<sigh> :^)

You turn on Option Strict to discover where you are making implicit castings at. And that is exaclty what it did.
Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."
Like I said, you are trying to shove a string (the result of either

function is a string, not a date) into a date variable. Hence "Option Strict On
disallows implicit conversions from 'System.Object' to 'Date'."

Don't do that!

If you want to display a date variable (pubLatest), then you must convert it to a string (using either method). Both of the functions return a STRING,
not a DATE. So you cannot store it back into a DATE variable. (Well, you
can with Option strict off, but it is just casting it back to a DATE
implicitly.)

Make a new variable (say "s")

Public s As String
s = FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Now use "s" to display it your date variable as a formatted string.

Debug.Writeline(s)

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ux*************@TK2MSFTNGP11.phx.gbl...
Thanks, Greg, we're getting there...still have some compile errors,
though.

pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
pubLatest.ToShortDateString()

Give me error: 'ToShortDateString' is not a member of 'String'.
-- and --

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Gives me error: "Option Strict On disallows implicit conversions from
'System.Object' to 'Date'."

_____
DC G

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
Place Option Strict On at the top of your file!!!

When you do you will see this will not compile:

Public pubLatest As Date
pubLatest =
FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
DateFormat.ShortDate)

Without Option Strict you are just playing a casting game. Casting a
sqldate to a string back to a date

If you want to format it for display, then stuff the result of either

method
into a STRING, not a date variable.

Greg

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
> Still no luck...neithr of these work...they both return times...
>
> Could it be because of my declaration?
>
> Public pubLatest As Date
> pubLatest =
> FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value,
> DateFormat.ShortDate)
>
> pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Valu e
> pubLatest.ToShortDateString()
>
>
>
> "Brian" <ja*****@amc.com> wrote in message
> news:38**********************************@microsof t.com...
>> Did you try pubLatest.ToShortDateString()?
>>
>> Brian
>>
>> "DC Gringo" wrote:
>>
>> > Thank you...
>> >
>> > The only thing that did was set my time to 12:00
>> >
>> > pubLatest =
>> > FormatDateTime(Me.SqlSelectCommand1.Parameters("@p ubLatest").Value, >> > DateFormat.ShortDate)
>> >
>> > ______
>> > DC G
>> >
>> > "Lucas Tam" <RE********@rogers.com> wrote in message
>> > news:Xn***************************@140.99.99.130.. .
>> > > "DC Gringo" <dc******@visiontechnology.net> wrote in
> news:e2T7mLQlEHA.3968
>> > > @TK2MSFTNGP11.phx.gbl:
>> > >
>> > > > How can I convert this pubLatest to a date with format

"m/d/yyyy"?
>> > > >
>> > >
>> > > Use the function FormatDateTime
>> > >
>> > > --
>> > > Lucas Tam (RE********@rogers.com)
>> > > Please delete "REMOVE" from the e-mail address when replying.
>> > > http://members.ebay.com/aboutme/coolspot18/
>> >
>> >
>> >
>
>



Nov 18 '05 #12

P: n/a
I need a cigarette. And I don't even smoke. :^)

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
Greg,

You are the man...it worked!

Sorry for the density upstairs over here...

_____
Glenn

Nov 18 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.