473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

convert to date format

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
12 3819
"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
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
"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
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
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
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
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
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
<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

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ohaya | last post by:
Hi, I'm working with a date string with a format as follows: Sat Dec 25 21:32:59 EST 2004 and I want to compare it to another date string of the format: 7/28/2004
2
by: Annie D via AccessMonster.com | last post by:
Hi, I am using the following SQL statement courtesy of access monster user: 'Terry Kreft ' to convert dates from a text format (20020331 00:00:00) to a recognised date/time format (31/03/2002)....
5
by: dubing | last post by:
Hello everyone, There is a field of DATETIME type in our Access 2000 database. PHP is used to query the data and display the query results on the web. Does Access provide any function that can...
1
by: prabhunew2005 | last post by:
I am using postgres,php in web designing. I have to convert date entered in MM-DD-YYYY format to YYYY-MM-DD format. I have to use resulting date format in my search sql. I used todate method. But i...
0
by: Swati Gunda | last post by:
Hello, I am working on C#. I want to convert system date which is by default in mm/dd/yyyy format into dd/mm/yyyy format. If you know the solution then plz reply me immediately. Thanks Swati
2
by: ManickavasagamSathiskumar | last post by:
hai I have one text box in asp page it for date entry field(dd/mm/yyyy)format user entered. But when i store in database it will store (mm/dd/yyyy) format how to change in asp.
7
chandru8
by: chandru8 | last post by:
I read the date from Notepad and convert it into date using Dateserial function. I try to convert it into my desired format like fomat( ,"dd/mm/yy") but I am unable to do that. Dim fs As New...
4
by: thomasc1020 | last post by:
This is regarding VB.NET 2003. Variable 'Date' is a string and it contains date information in this format: "DEC/05/2007". Now I am trying to convert the format as "2007-12-05". Is it...
3
Chittaranjan
by: Chittaranjan | last post by:
Hi All, I am not sure how to change the date format in PostgreSQL. I have the dates stored in the database as yyyy-mm-dd HH:MM:SS+TimeZone to get the GMT time (Ex: 2008-02-28 14:03:23+05:30). But...
2
by: anoop s | last post by:
Hi, In my web application I want fetch data from fixed width text file. I am using OLEDB connection for retrieving data. But the problem is the date format is dd/mm/yyyy in text file. Can I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.