Convert C++ time to DECL_DATETIME?

Hi

I was wondering how to convert a C++ type time value to a DECL_DATETIME 
so that I can compare them.

I have a 'from' datetime and a 'to' datetime and need to check if the 
current system time is withing that range.

Something like:

	time_t rawtime;
	struct tm * crtimeinfo;
	DECL_DATETIME dt;

	time( &rawtime );
	crtimeinfo = localtime( &rawtime );
	dt = crtimeinfo;

Is there a way to assign the time to a DECL_DATETIME without assigning 
each element (year, month, day....)?

Thanks,
Scott
0
Scott
11/17/2010 9:25:35 PM
sybase.sqlanywhere.ultralite 2982 articles. 0 followers. Follow

2 Replies
814 Views

Similar Articles

[PageSpeed] 47

Hi Scott,

The DECL_DATETIME structure is different than struct tm, so you would have 
to assign each element. That's still pretty efficient. mktime()/timegm() 
would then convert to a time_t value for comparison.

Are the 'from' and 'to' times in the database? In that case, you can use the 
now() SQL function to get the current system time and just write the 
comparison as part of a SQL query (or fetch it). This would be preferable 
because then all the time stuff is handled by the database and you don't 
have to worry about how to convert things yourself. Does that make sense?

Regards,
- Tim


"Scott Trafford" <scott@rci.ca> wrote in message 
news:4ce4484f@forums-1-dub...
> Hi
>
> I was wondering how to convert a C++ type time value to a DECL_DATETIME so 
> that I can compare them.
>
> I have a 'from' datetime and a 'to' datetime and need to check if the 
> current system time is withing that range.
>
> Something like:
>
> time_t rawtime;
> struct tm * crtimeinfo;
> DECL_DATETIME dt;
>
> time( &rawtime );
> crtimeinfo = localtime( &rawtime );
> dt = crtimeinfo;
>
> Is there a way to assign the time to a DECL_DATETIME without assigning 
> each element (year, month, day....)?
>
> Thanks,
> Scott 


0
Tim
11/25/2010 6:47:47 PM
Tim

Thanks for the response.  I actually used a combo of both.  My select 
statement was greatly simplified w/ using now().

Thanks,
Scott

On 25/11/2010 1:47 PM, Tim McClements [Sybase] wrote:
> Hi Scott,
>
> The DECL_DATETIME structure is different than struct tm, so you would have
> to assign each element. That's still pretty efficient. mktime()/timegm()
> would then convert to a time_t value for comparison.
>
> Are the 'from' and 'to' times in the database? In that case, you can use the
> now() SQL function to get the current system time and just write the
> comparison as part of a SQL query (or fetch it). This would be preferable
> because then all the time stuff is handled by the database and you don't
> have to worry about how to convert things yourself. Does that make sense?
>
> Regards,
> - Tim
>
>
> "Scott Trafford"<scott@rci.ca>  wrote in message
> news:4ce4484f@forums-1-dub...
>> Hi
>>
>> I was wondering how to convert a C++ type time value to a DECL_DATETIME so
>> that I can compare them.
>>
>> I have a 'from' datetime and a 'to' datetime and need to check if the
>> current system time is withing that range.
>>
>> Something like:
>>
>> time_t rawtime;
>> struct tm * crtimeinfo;
>> DECL_DATETIME dt;
>>
>> time(&rawtime );
>> crtimeinfo = localtime(&rawtime );
>> dt = crtimeinfo;
>>
>> Is there a way to assign the time to a DECL_DATETIME without assigning
>> each element (year, month, day....)?
>>
>> Thanks,
>> Scott
>
>

0
Scott
12/6/2010 10:21:48 PM
Reply:

Similar Artilces:

Convert from epoch UTC time to human readable time in .NET C# ?
Hello, I have the epoch UTC time format and I want to convert it back to human readable time in C#? How do I do it? Here is the current epoch time that I just generated: epoch = 1225815911 and how do I convert it back to human readable time? Thanks Hi,To convert from epoch UTC (which should be 1/1/1970 00:00:00 UTC) to a human readable time, you'll need to find the number of ticks between the DateTime class' base time (1/1/0001 00:00:00) to epoch time. You multiply your epoch time by the tick resolution (100 nanoseconds / tick) and add your base ticks (epoch time - base...

Instant C++ C# to C++ Converter
We've just released version 1.0 of the Instant C++ C# to C++ converter.  Instant C++ converts to either C++/CLI (2005) or Managed C++ (2003).Instant C++ converts C# projects, folders, files, and snippets. David Antonwww.tangiblesoftwaresolutions.comInstant C#: VB.NET to C# ConverterInstant VB: C# to VB.NET ConverterInstant C++: C# to C++ ConverterInstant J#: VB.NET to J# ConverterClear VB: Cleans up outdated VB.NET code David Antonhttp://www.tangiblesoftwaresolutions.comConvert VB to C#, C++, or JavaConvert C# to VB, C++, or JavaConvert C++ to C#, VB, or JavaConvert Java to C#, C++, or...

converting some C# to C++
Hi, I'm converting some code written in C# and came across something tricky. The C# code looks like this <code> internal static string[] GetStringArrayFromPtrLA(IntPtr pointer, int nLength) { IntPtr[] rawRows = new IntPtr[nLength]; string[] oResult = new string[nLength]; Marshal.Copy(pointer, rawRows, 0, nLength); for (int i = 0; i < nLength; i++) { oResult[i] = Marshal.PtrToStringAnsi(rawRows[i]); } // for (int) ..... </code> I have had some success. If the pointer is pointing to an array of ...

CONVERT TEXT to Date time in formview and C#
 Hi Here I have a question. my form viwew has a textbox which takes date from calendar and I converted the string in ASPX.CS to date. If I edit the textbox erase what ever in the textbox that bound from Database and make the textbox to "null" value, hit update The date is not gone away. It still shows the samedate that is bound from DB. Here is some code.<asp:TextBox ID="Date_RegBox" runat="server" Text='<%# Bind("[Registration_Date]","{0:d}") %>'></asp:TextBox>        &nb...

Convert C++ code to C#
Hi! All,   May I know is there any free converter available that can convert C++ code to C# code? Any reply is much appreciated.   Regards The Demo version here allows up to 100 lines at a time: http://www.tangiblesoftwaresolutions.com/Regards Mike [MVP - ASP/ASP.NET]My site Yes, but unmanaged c++ however should be converted manually. My experience. Throw up your code and let all all help in? :P(not sure about how many volunteers)Please Mark Post that helped you as answer, also include a summary of what solved the problem as it helps others in similar situations...

HELP- SqlAnyWhere X SqlWindows(cannot convert to the date/time)
Does some way exist of converting the type Date/time of SQLWindows for Timestamp of SqlAnyWhere? (using bind variable certainly) When I use bind variable of Centura type Date/Time, in the insert, in the update or in the cluasula where of the select. (Example: Call SqlImmediate('UPDATE g_acidente set acid_dt_cadastro =:dData where acid_cod = 1 ') I have the error message: 'Sybase SQL Anywhere:-157[Sybase][ODBC Driver]: cannot convert to the date/time ' Please, as I solve that? Obs: I want to use bind variable of the type Datetime. ...

Convert EST to IST (server time zone problem) in asp.net (C#)
hi, I want to Convert EST to IST time zone. i required IST time in my project. (asp.net (C#)) thanks and regards, dhemittal@gmail.com If you are using Asp.Net 3.5 try this code..  DateTime time1 = new DateTime(2008, 12, 11, 6, 0, 0); // your DataTimeVariable TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime newTime = TimeZoneInfo.ConvertTime(time1, timeZone1, timeZone2); My Blog"Don't be afraid to be wrong; o...

Converting UTC times to local times?
DateTime values are stored in UTC in the database. For reporting, how can I display these values in local time?If a post helps me I'll always eventually mark it as an answer. But I frequently don't mark it right away because I feel once a thread is marked as answered, discussion tends to end. And I like to discuss things a bit.  I finally found the answer through google:=System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!DateTime.Value) If a post helps me I'll always eventually mark it as an answer. But I frequently don't mark it right away because I feel once ...

Converting to UTC time from stored time
I have to get the local time from a table which the UTC time was stored. Is there anyway or function I can do this with? I couldn't figure out because of daylight saving time and how the "daylight saving time" time was change. So, to summarize, i just want to ask if there are functions so I can convert from and to UTC time? Thanks, Kevin ...

Convert military time to normal time
Hi. I've got a time value from the database as 0800 coming to the page as a string. I'd like to convert this to normal time: 8:00 a.m. (it might also be null). How do I do this in ASP.NET 2.0? Since it can be null, here's the best way to do it. string m_DateTime_String = "0800";m_DateTime_String = m_DateTime_String.Insert(2, ":"); DateTime m_DateTime_Result; bool m_DateTime_Parse;m_DateTime_Parse = DateTime.TryParse(m_DateTime_String, out m_DateTime_Result); if (m_DateTime_Parse){   string m_RegularTime = m_DateTime_Result.ToShortTimeString();} HTH,RyanRyan OlshanASPIn...

convert C# char to C char
Does anyone now how to pass a C# char to unmanaged C char? The big difference is the C char is an 8 bit char and a C# is 16 bit. I can use the encode method but that creates a byte[]. I can't figure this out. Jim "It is kind of fun to do the impossible" - Walt Disney...

HOW TO: convert VB into C# and C# into VB
have noticed people asking this question a little throughout the forum, so as an FYI here's a pretty decent code converter:http://converter.telerik.com/does anybody else have some decent online asp.net code converting tools to share? thanks sir www.developerfusion.co.uk/utilities/convertcsharptovb.aspxRegardsSatheesh Kumar K Khttp://www.quesbank.com www.developerfusion.co.uk/utilities/convertvbtocsharp.aspxRegardsSatheesh Kumar K Khttp://www.quesbank.com One more, I noticed at http://www.dotnetspider.com/  A few more to share:http://authors.aspalliance.com/aldotnet/examples/tran...

static linking /Load-time dynamic,' .dll' linking in C# interaction with C++ .dll in C#
Hi all,                 I have to give a static Link to .dll file in C#,                 I have the following three files for that ‘.dll’ file in C++ 1.       *.h  file 2.       *.lib file 3.       *.dll (Unmanaged) file Give me a small Example of Static linking /Interact with that non typed DLL. Thanks & Regards,Murthy....

is there some tools to convert the c# to msil or msil to c#??
hello: i am studing the msil,and i want to know the converted code between the c# and msil(i wrote some code with c# or msil and translate it into msil or c#),is there some tools to do this,please help me,thank you. Converting from C# to MSIL is what you do when you compile a program in Visual Studio. The probably best tool to go in the other direction (reverse compilation) is Reflector, http://www.aisto.com/roeder/dotnet/ . SvanteAxCrypt - Free Open Source File Encryption & Online Password Manager - http://www.axantum.com[Disclaimer: Code snippets usually uncompiled, beware typo...

Web resources about - Convert C++ time to DECL_DATETIME? - sybase.sqlanywhere.ultralite

Resources last updated: 12/5/2015 3:29:38 AM