Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extraction from date (2003 (SP2))

    I'm trying to change a standard date value into the date format used by our AS400 system (this is year - 1900 & mm & dd e.g. 1st Jan this year = 1060101). I'm using 'Datepart' but I'm running into a couple of problems;

    Datepart doesn't give leading zeros that I need & mid seems to do the same
    Concatenating the results sometimes gives overflow.
    Here's the code I'm trying to get to work;

    Dim intEIStest As Integer
    Dim sngEISyr As Single
    Dim sngEISmnth As Single
    Dim sngEISday As Single

    sngEISyr = (DatePart("yyyy", txtDateFrom) - 1900)
    sngEISmnth = DatePart("m", txtDateFrom)
    sngEISday = DatePart("d", txtDateFrom)
    intEIStest = sngEISyr & sngEISmnth & sngEISday

    txtTest.Value = intEIStest

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Extraction from date (2003 (SP2))

    You shouldn't use Integers or Singles here, but Longs.
    Integers only go as high as 32,767, and Singles are for numbers with decimal places.

    Dim lngEIStest As Long
    Dim lngEISyr As Long
    Dim lngEISmnth As Long
    Dim lngEISday As Long

    lngEISyr = Year(txtDateFrom) - 1900
    lngEISmnth = Month(txtDateFrom)
    lngEISday = Day(txtDateFrom)
    lngEIStest = 10000 * lngEISyr + 100 * lngEISmnth + lngEISday

    txtTest.Value = lngEIStest

  3. #3
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Extraction from date (2003 (SP2))

    As simple as that <img src=/S/blush.gif border=0 alt=blush width=15 height=15>. Works a treat now.

    Many thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •