# Date in new framework

**URL:** <https://forum.xojo.com/t/date-in-new-framework/41535>\
**Category:** General\
**Created:** [January 11, 2018, 4:37am UTC](https://forum.xojo.com/t/date-in-new-framework/41535 "2018-01-11T04:37:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryan\_Dodson](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/ba8739/32.png) [@Bryan\_Dodson](https://forum.xojo.com/u/Bryan_Dodson)\
**Post date:** [January 11, 2018, 4:37am UTC](https://forum.xojo.com/t/date-in-new-framework/41535/1 "2018-01-11T04:37:50Z")

</div>

I am lost with the new date. The code that is commented out  
//Dim D As New Xojo.Core.Date(2015, 9, 1, 15, 20, 30, 0, Xojo.Core.TimeZone.Current)  
works, but when I replace hard typed integers with actual integers, I get a syntax error with the following code.  
Dim D As New Xojo.Core.Date(yy, mo, dd, hh, mi, , 0, 0, Xojo.Core.TimeZone.Current)

Any ideas?

[code]//161001\_0300 The incoming format is yymmdd\_hhmm

Using Xojo.Core

Dim yy as Int64  
Dim mo as Int64  
Dim dd as Int64  
Dim hh as Int64  
Dim mi as Int64

yy = CLong(left(t,2)) + 2000

if mid(t,3,1) = “0” then  
mo = CLong(mid(t,4,1))  
else  
mo = CLong(mid(t,3,2))  
end if

if mid(t,5,1) = “0” then  
dd = CLong(mid(t,6,1))  
else  
dd = CLong(mid(t,5,2))  
end if

if mid(t,8,1) = “0” then  
hh = CLong(mid(t,9,1))  
else  
hh = CLong(mid(t,8,2))  
end if

if mid(t,10,1) = “0” then  
mi = CLong(mid(t,11,1))  
else  
mi = CLong(mid(t,10,2))  
end if

Dim D As New Xojo.Core.Date(yy, mo, dd, hh, mi, , 0, 0, Xojo.Core.TimeZone.Current)  
//Dim D As New Xojo.Core.Date(2015, 9, 1, 15, 20, 30, 0, Xojo.Core.TimeZone.Current)

Return D

[/code]

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [January 11, 2018, 5:19am UTC](https://forum.xojo.com/t/date-in-new-framework/41535/2 "2018-01-11T05:19:28Z")

</div>

There is a comma without a parameter: "mi, , " . You probably stared at the code too long.

Also the code is pretty weird:

`if mid(t,3,1) = "0" then
  mo = CLong(mid(t,4,1))
else
  mo = CLong(mid(t,3,2))
end if
`

What do you think this does? Replace this with:

```auto
 mo = CLong(mid(t,3,2))
```

---

<div class="post-metadata">

**Author:** ![Antonio\_Rinaldi](https://forum.xojo.com/user_avatar/forum.xojo.com/antonio_rinaldi/32/331_2.png) [@Antonio\_Rinaldi](https://forum.xojo.com/u/Antonio_Rinaldi)\
**Post date:** [January 11, 2018, 8:51am UTC](https://forum.xojo.com/t/date-in-new-framework/41535/3 "2018-01-11T08:51:45Z")

</div>

Maybe in this way is easier:  
//161001\_0300 The incoming format is yymmdd\_hhmm  
//if it is a string then convert it to Text (using .ToText)  
//now you have t as text =“161001\_0300”

dim txtDate as text=“20”+t.Left(2)+"-"+t.Mid(2,2)+"-"+t.Mid(4,2)+" “+t.Mid(7,2)+”:"+t.Right(2)+":00"  
dim d as Xojo.Core.Date=Xojo.Core.Date.fromText(txtDate)

//d is in your current timeZone

---

<div class="post-metadata">

**Author:** ![Bryan\_Dodson](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/ba8739/32.png) [@Bryan\_Dodson](https://forum.xojo.com/u/Bryan_Dodson)\
**Post date:** [January 11, 2018, 1:52pm UTC](https://forum.xojo.com/t/date-in-new-framework/41535/4 "2018-01-11T13:52:34Z")

</div>

Unbelievable. I look at the code for a couple hours, and even re-typed it.

Antonio - thanks for the much simpler approach!

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:03pm UTC](https://forum.xojo.com/t/date-in-new-framework/41535/5 "2020-10-29T19:03:48Z")

</div>


