# Problem with setting DateTime variable

**URL:** https://www.finalbuilder.com/forums/t/problem-with-setting-datetime-variable/1720
**Category:** Discussion
**Created:** [March 14, 2011, 1:07am UTC](https://www.finalbuilder.com/forums/t/problem-with-setting-datetime-variable/1720 "2011-03-14T01:07:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![traptak](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/dec6dc/32.png) [@traptak](https://www.finalbuilder.com/forums/u/traptak)
#### Post date: [March 14, 2011, 1:07am UTC](https://www.finalbuilder.com/forums/t/problem-with-setting-datetime-variable/1720/1 "2011-03-14T01:07:12Z")

</div>

Hello,

I have problem with setting DateTime to the variable using JScript in FinalBuilder. I have following script:

var date = new Date();  
Action.SendLogMessage("New date");  
date.setTime(FBVariables.p\_SectionLastRunTimeUTC);  
Action.SendLogMessage("Set time: " + date.toString());  
FBVariables.p\_SectionLastRunTime = date; &nbsp;\<---- Here is an error  
Action.SendLogMessage("Set last time");  
  
&nbsp;

Variable:&nbsp;p\_SectionLastRunTimeUTC is integer, variable&nbsp;p\_SectionLastRunTime is DateTime. I'm using FinalBuilder 7.0.0.1065

&nbsp;

How it should be done correctly?&nbsp;

--

best regards&nbsp;

Adam Siwon

&nbsp;

---

<div class="post-metadata">

### Author: ![stephen.ryan](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@stephen.ryan](https://www.finalbuilder.com/forums/u/stephen.ryan)
#### Post date: [March 15, 2011, 5:33am UTC](https://www.finalbuilder.com/forums/t/problem-with-setting-datetime-variable/1720/2 "2011-03-15T05:33:44Z")

</div>

Hi Adam   
  
 The problem here is that the FinalBuilder DateTime variable type is the Delphi TDateTime type, which is why your script is failing when you attempting to assign a javascript date type to your variable.   
  
 If you change your variable type to Variant this will work correctly.   
  
 Regards,   
 Steve

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [March 15, 2011, 12:08pm UTC](https://www.finalbuilder.com/forums/t/problem-with-setting-datetime-variable/1720/3 "2011-03-15T12:08:13Z")

</div>

It might also work if you use VBScript as I believe the VBScript Date type is compatible with Delphi (they are both com compatible datetimes).
