Link to home
Start Free TrialLog in
Avatar of aaxen
aaxen

asked on

convert date into integer

how do i convert date for example 22/07/2008 to 22072008?
dim curdate as date = now
dim reference as integer

Open in new window

Avatar of VBRocks
VBRocks
Flag of United States of America image

       Dim dt As Date = #12/7/2008#

        Dim dtInt As Integer = CInt(dt.Month & dt.Date & dt.Year)

        MsgBox (dtInt)

Avatar of aaxen
aaxen

ASKER

it says conversion from string "1212/7/20082008" to type 'integer' is not valid
Dim dt As Date = #12/7/2008#

Dim dtInt As Integer = (0 & CInt(dt.Month)) & (0 & CInt(dt.Day)) & CInt(dt.Year)

MsgBox(dtInt)
I'm sorry, I meant to put "Day", not "Date"

       Dim dt As Date = #12/7/2008#

        Dim dtInt As Integer = CInt(dt.Month & dt.Day & dt.Year)

        MsgBox (dtInt)

Am i right in thinking this is for VB.NET and not VB?
       Dim dt As Date = new Date(1983,4,21)
        Dim dtInt As Integer = Convert.ToInt32(dt.ToString("yyyyMMdd"))
 
        MessageBox.Show(dtInt.ToString())

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial