c++ win32 , equivilent to DateTime.Now() in asp.net
-
Is there an equivilent to the DateTime.Now() in asp.net, I'm writing a time stamp to sql server, and wanted to keep the same format.
dbUA->pzDateOpened = some sort of DateTime.Now();
GetCurrentTime() function should work for you. [^]
Every new day is another chance to change your life.
-
Is there an equivilent to the DateTime.Now() in asp.net, I'm writing a time stamp to sql server, and wanted to keep the same format.
dbUA->pzDateOpened = some sort of DateTime.Now();
Hi, You can use GetLocalTime().. SYSTEMTIME st; GetLocalTyme(&st); Thanks, Satheesh
-
Hi, You can use GetLocalTime().. SYSTEMTIME st; GetLocalTyme(&st); Thanks, Satheesh
-
GetCurrentTime() function should work for you. [^]
Every new day is another chance to change your life.
-
Is there an equivilent to the DateTime.Now() in asp.net, I'm writing a time stamp to sql server, and wanted to keep the same format.
dbUA->pzDateOpened = some sort of DateTime.Now();
-
According to MSDN _ftime[^] is the equivalent.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
Thanks for the help Richard. I was trying to inject the results into a datetime column in SQL via ODBC, but between the 2, it was hard to nail down the error. I didn't know if it was the format of the data, or ODBC not wanting to accept the LPSYSTEMTIME structure, or the size/precision of the data, which for some reason is 23,3. Ended up with this for now, it works, I can modify it later if I find something better.
SYSTEMTIME systemTime;
GetSystemTime(&systemTime);
LPSYSTEMTIME lpSystemTime = &systemTime;swprintf_s(szDateOpened,
L"%d-%d-%d %d:%d:%d",
systemTime.wMonth,
systemTime.wDay,
systemTime.wYear,systemTime.wHour, systemTime.wMinute, systemTime.wSecond );
szDateOpened[wcslen(szDateOpened)] = L'\0';
And then sent it to the ODBC Driver in another function. I just need to figure how how to create a MD5 Hash in UT8 for the Encoded Password, and then this part of the program is done.
L"INSERT INTO UserInfo(FirstName, LastName, UserName, PhraseHint, Phrase, PasswordClear, DateOpened, Email, FrontAdmin, SecurityLevel, Enabled, LastLogin) "
L"VALUES(?, ?, ?, ?, ?, ?, CAST(? as datetime), ?, ?, ?, ?, CAST(? AS datetime) )"and parameterized the values, that one liner took all day long.
retcode = SQLBindParameter(hstmt, 12, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 23, 3, pzLastLogin, wcslen(pzLastLogin), NULL);
-
Thanks for the help Richard. I was trying to inject the results into a datetime column in SQL via ODBC, but between the 2, it was hard to nail down the error. I didn't know if it was the format of the data, or ODBC not wanting to accept the LPSYSTEMTIME structure, or the size/precision of the data, which for some reason is 23,3. Ended up with this for now, it works, I can modify it later if I find something better.
SYSTEMTIME systemTime;
GetSystemTime(&systemTime);
LPSYSTEMTIME lpSystemTime = &systemTime;swprintf_s(szDateOpened,
L"%d-%d-%d %d:%d:%d",
systemTime.wMonth,
systemTime.wDay,
systemTime.wYear,systemTime.wHour, systemTime.wMinute, systemTime.wSecond );
szDateOpened[wcslen(szDateOpened)] = L'\0';
And then sent it to the ODBC Driver in another function. I just need to figure how how to create a MD5 Hash in UT8 for the Encoded Password, and then this part of the program is done.
L"INSERT INTO UserInfo(FirstName, LastName, UserName, PhraseHint, Phrase, PasswordClear, DateOpened, Email, FrontAdmin, SecurityLevel, Enabled, LastLogin) "
L"VALUES(?, ?, ?, ?, ?, ?, CAST(? as datetime), ?, ?, ?, ?, CAST(? AS datetime) )"and parameterized the values, that one liner took all day long.
retcode = SQLBindParameter(hstmt, 12, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 23, 3, pzLastLogin, wcslen(pzLastLogin), NULL);
I'm afraid my SQL skills are non-existent, but I would suggest you do not store dates and/or times as text values in a database but as datetime (i.e. binary) values. The remarks section in the documentation[^] suggest how to convert it to a large integer. This seems like a lot of work just to save a simple value, but it is Microsoft.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Is there an equivilent to the DateTime.Now() in asp.net, I'm writing a time stamp to sql server, and wanted to keep the same format.
dbUA->pzDateOpened = some sort of DateTime.Now();
Hi, SYSTEMTIME st; GetLocalTime(&st); CString strHour, strMinute, strSecond; strHour.Format(_T("%d"), st.wHour); strMinute.Format(_T("%d"), st.wMinute); strSecond.Format(_T("%d"), st.wSecond); You can use this to get the current time. I f you need to update the time automatically.Use a timer with one second elapse time, and use this code in OnTimer(). Thanks
-
I'm afraid my SQL skills are non-existent, but I would suggest you do not store dates and/or times as text values in a database but as datetime (i.e. binary) values. The remarks section in the documentation[^] suggest how to convert it to a large integer. This seems like a lot of work just to save a simple value, but it is Microsoft.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman