Archive for the ‘Date’ Category

Date

Posted: 2017-01-17 in Date

Q:
in WebView (report) it’s displayed ok (e.g. “German”)…
A:
Dates in the Web Client are displayed in ANSI format so to be independent of the locale of the user.
The format is:
yyyy-mm-dd or yyyy-mm-dd hh:ii:ss
WebView report is generated server side using a dynamic server page which is why it can display an alternative date format to ANSI.


Q:
if I type:

Code:
a = timeofday(3)
b = timeofday(3)
c = b-a
? c...

I got the “string” 40534.37340526.850..
A:
Timeofday(4) returns the difference – the elapsed time between calling timeofday().
Timeofday() returns a character value.

Code:
a = timeofday(3)
? type("a")
C
? vartype(a)
C

Q:
What will be the date format of a Lianja table if record is inserted through Lianja ODBC ?
What is the default the century setting ?
A:
Lianja ODBC uses ISO format dates: YYYY-MM-DD; Century is ON.


Q:
I tried to update date field in my Lianja table from VFP 9.0 sp2 through Lianja ODBC and my date setting was YMD. The command is

Code:
? sqlexec(lnConnHandle, "update mytable set dated = {2015/05/14 09:29:02}")

The command is successfully executed but when I fetched data from Lianja table, it showed NULL is saved in my table.
If I save {2015-05-14 09:29:02} then the datetime value is stored perfectly. Is there a way to set date mark ‘-‘ to ‘/’ for Lianja ODBC ?
A:
Dates are set to ISO internally, so you would need to convert the value you are sending, e.g.
ctot(strtran(“2015/05/14 09:29:02″,”/”,”-“))


Q:
know how the syntax for dates with Visual FoxPro to ODBC lianja.
I’m trying several but do not work:

Code:
ffin=date()
myselect="SELECT * FROM FACTDIG WHERE FCHFACTURA<={?ffin}"
myselect="SELECT * FROM FACTDIG WHERE FCHFACTURA<=?ffin"
myselect="SELECT * FROM FACTDIG WHERE FCHFACTURA<={ts '01/29/2015 00:00:00'}"
if lnConnHandle > 0
sqlexec(lnConnHandle,myselect,"FACTDIG")
else 
messagebox("Sin Conexion","Error")
RETURN .F.
endif

A:

Code:
// TYPE("employees_calendar.eventstart") = "T" 
lc = SQLCONNECT("Lianja_Southwind")
m_datetime = TTOC(DATETIME(),1)
? SQLEXEC(lc,"select * from employees_calendar where eventstart < stot(?m_datetime)")
SQLDISCONNECT(lc)

// TYPE("orders.orderdate") = "D"
lc = SQLCONNECT("Lianja_Southwind")
m_date = DTOS(DATE())
? SQLEXEC(lc,"select * from orders where orderdate < stod(?m_date)")
SQLDISCONNECT(lc)

this is ok:

Code:
Xfini = DTOS(FINI)
Xffin = DTOS(FFIN)
myselect="SELECT * FROM FACTDIG WHERE FCHFACTURA>= stod(?XFINI) AND FCHFACTURA<= stod(?XFFIN) ORDER BY FACTDIG.FCHFACTURA"


Date

Posted: 2015-11-07 in Date

Here’s an example that returns DD/MM/YY – I’m calling it from the click of a commandbutton in a canvas section. My function is just in the section custom library here.

Code:
function formatDate(d) {
  var dd = d.getDate();
  if ( dd < 10 ) dd = '0' + dd;
   var mm = d.getMonth()+1;
  if ( mm < 10 ) mm = '0' + mm;
  var yy = d.getFullYear() % 100;
  if ( yy < 10 ) yy = '0' + yy;
return dd+'/'+mm+'/'+yy;

}
////////////////////////////////////////////////////////////////
// Event delegate for 'click' event
function page1_section1_field1_click()
{
        var currentdate = new Date();
        messagebox(formatDate(currentdate));
}


Lianja dates start at 1/1/1900.



The TTOC() function is used to format datetimes.
I have enhanced it in v1.3Beta6 to handle ISO 8601. See below.

Screen Shot 2014-11-25 at 1.24.45 PM