equivalent Dateserial(),DateAdd() ...

  1. last week

    Djamel A

    Oct 10 Oran (Algeria)

    Hello,
    Is there any equivalent xojo functions to vb6 DateSerial() and DateAdd() ?

    again... using new framework you get the notion of intervals

    Using Xojo.Core
    Dim twoMonths As New DateInterval
    twoMonths.Months = 2 ' 2 month interval
      
    ' Get date two months from today
    Dim future As Date = Date.Now + twoMonths
  2. Kem T

    Oct 10 Pre-Release Testers, Xojo Pro, XDC Speakers New York
    dim d as new Date( 2018, 10, 10 )
    
    const kDays = 60.0 * 60.0 * 24.0
    d.TotalSeconds = d.TotalSeconds + ( 2 * kDays )

    See:

    http://developer.xojo.com/date

  3. Jean-Yves P

    Oct 10 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited last week
    Using Xojo.Core
    Dim twoMonths As New DateInterval
    twoMonths.Months = 2 ' 2 month interval
      
    ' Get date two months from today
    Dim future As Date = Date.Now + twoMonths

    see http://developer.xojo.com/xojo-core-date

  4. Djamel A

    Oct 10 Oran (Algeria)

    @Kem T dim d as new Date( 2018, 10, 10 ) const kDays = 60.0 * 60.0 * 24.0 d.TotalSeconds = d.TotalSeconds + ( 2 * kDays )

    See:

    http://developer.xojo.com/date

    In Vb6: DateSerial(1967, 2, 31) 03/03/1967 Auto Correct Invalid Date.

  5. Kem T

    Oct 10 Pre-Release Testers, Xojo Pro, XDC Speakers New York

    Did you try it?

  6. Djamel A

    Oct 10 Oran (Algeria)

    @Kem T dim d as new Date( 2018, 10, 10 ) const kDays = 60.0 * 60.0 * 24.0 d.TotalSeconds = d.TotalSeconds + ( 2 * kDays )

    your code return the number of seconds since 1970 i suppose : 3622147200.000000 sec

  7. Kem T

    Oct 10 Pre-Release Testers, Xojo Pro, XDC Speakers New York

    My code created a Date object. Please look at the developer page I referenced for more information.

  8. Djamel A

    Oct 10 Oran (Algeria)

    @Kem T My code created a Date object. Please look at the developer page I referenced for more information.

    I did not found equivalent :
    DateAdd(interval, number, date)
    interval required (can be second(s),minute(n),hour(h),day(d),month(m),year(yyyy), etc ...). The interval you want to add.
    number Required.
    The number of interval you want to add. Can either be positive, for dates in the future, or negative, for dates in the past.
    (Long)
    date Required. Variant or literal representing the date to which interval is added.

    Understood, with TotalSeconds we can do many date operation like add(),serial(), etc ...

  9. Jean-Yves P

    Oct 10 Pre-Release Testers, Xojo Pro Answer Europe (France, Besançon)
    Edited last week

    again... using new framework you get the notion of intervals

    Using Xojo.Core
    Dim twoMonths As New DateInterval
    twoMonths.Months = 2 ' 2 month interval
      
    ' Get date two months from today
    Dim future As Date = Date.Now + twoMonths
  10. 5 days ago

    Djamel A

    Oct 12 Oran (Algeria)

    @Jean-YvesPochez again... using new framework you get the notion of intervals
    Using Xojo.Core Dim twoMonths As New DateInterval twoMonths.Months = 2 ' 2 month interval ' Get date two months from today Dim future As Date = Date.Now + twoMonths This cas gives same date as Date.Now even for min, etc ...

      Using Xojo.Core
      Dim twoMonths As New DateInterval
      dim minute as New DateInterval
      dim second as New DateInterval
      dim dy as New DateInterval
      twoMonths.Months = 1
      dy.Days=29
      minute.Minutes =59
      second.Seconds = 30
      
      ' Get date two months from today
      Dim future As Date = Date.Now + twoMonths
      
      Tdate.text = future.ToText

or Sign Up to reply!