ADO getting DATETIME type

I tried to get the DATETIME data type from SQL Server using ADO in
VC++.

The DATETIME value shown in SQLServer is 
3/20/2008 2:00:00 AM

But when I look at the vtValue object in VC++ debugger it looks
something like:

tagVARIANT	DATE =  39527.083333333336	
		vt	7	unsigned short
		DATE	39527.083333333336	double

How can I modify the following code to get the correct DATEIMTE?


=========================
_variant_t  vtValue;
vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
FieldValue=vtValue.date;

=========================

bool Table::Get(char* FieldName,int& FieldValue)
{
_variant_t  vtValue;
vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
FieldValue=vtValue.date;
return 1;
}
0
3/27/2008 8:06:05 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
1193 Views

Similar Articles

[PageSpeed] 59

Eric Kaplan wrote:
> I tried to get the DATETIME data type from SQL Server using ADO in
> VC++.
> 

c.l.c++ isn't the place to ask.

-- 
Ian Collins.
0
ian-news (4)
3/27/2008 8:16:02 PM
Eric Kaplan <tobycraftse@yahoo.com> wrote:
> I tried to get the DATETIME data type from SQL Server using ADO in
> VC++.
>
> The DATETIME value shown in SQLServer is
> 3/20/2008 2:00:00 AM
>
> But when I look at the vtValue object in VC++ debugger it looks
> something like:
>
> tagVARIANT DATE =  39527.083333333336

DATE is a typedef for double. It stores the number of days since some 
epoch (don't remember which). Fractional part represents the time of day 
(0.5 is noon, 0.75 is 6pm and so on). See also VariantTimeToSystemTime, 
SystemTimeToVariantTime.

> vt 7 unsigned short

7 is VT_DATE, signalling that the VARIANT does indeed contain a date.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925


0
itandetnik (127)
3/27/2008 8:38:52 PM
Hi Eric,

> I tried to get the DATETIME data type from SQL Server using ADO in
> VC++.
> 
> The DATETIME value shown in SQLServer is
> 3/20/2008 2:00:00 AM
> 
> But when I look at the vtValue object in VC++ debugger it looks
> something like:
> 
> tagVARIANT DATE =  39527.083333333336
> vt 7 unsigned short
> DATE 39527.083333333336 double

VariantTimeToSystemTime should help.

--
SvenC
0
SvenC1 (13)
3/27/2008 8:41:05 PM
give I have the following function, how to modify the code to return a
String of the DATETIME using VariantTimeToSystemTime?


bool Table::Get(char* FieldName,int& FieldValue)
{
_variant_t  vtValue;
vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
FieldValue=vtValue.date;
return 1;
}



>DATE is a typedef for double. It stores the number of days since some 
>epoch (don't remember which). Fractional part represents the time of day 
>(0.5 is noon, 0.75 is 6pm and so on). See also VariantTimeToSystemTime, 
>SystemTimeToVariantTime.
>
>> vt 7 unsigned short
>
>7 is VT_DATE, signalling that the VARIANT does indeed contain a date.
0
3/27/2008 10:04:38 PM
Eric Kaplan <tobycraftse@yahoo.com> wrote:
> give I have the following function, how to modify the code to return a
> String of the DATETIME using VariantTimeToSystemTime?

Try VariantChangeType instead, change the type to VT_BSTR. Or use 
VarBstrFromDate. Or, if you want to convert to SYSTEMTIME first, see 
GetDateFormat and GetTimeFormat.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925


0
itandetnik (127)
3/27/2008 10:10:57 PM
Reply:

Similar Artilces:

Trying to Get Subset of XML
I want to display a segment of an XML (see below) file in a datagrid. I want to select a specific <EventID> and get all of its children into a dataset so that I can bind a datagrid to those values. I am trying an expression as follows but I get an error "Value of type 'System.Xml.XmlNode' cannot be converted to 'System.Xml.XmlNodeList'." myNodes = xmldoc.ChildNodes("/Dataset/Events/[ShowName=Round 2]") What is the correct way to "get" that set of nodes and convert them to a dataset? ================== Portion of XML File ===============...

Why is Excel getting hosed everytime I try to save my file?
Twice a month I update an Excel file to store our household finances and bills when I pay bills. It has worked fine until about 2 months ago. When I would close it, Excel would enter into Not Responding mode. I tried manually saving the file before I close it and even while I am still working in it and it still gets hosed. I can recover the file , thankfully, with the office automatic recover feature, but it is very annoying. Any ideas what is going on and what I can do to fix it? Hi, I had something similar, ik may be that there is a 'missing bit or byte' in the file which c...

Error Message "Bad Type For Word Wrap"
We revised the Edit Payables List and ever since we started using the modified version when we go to print it- the message "Bad Type for Word Wrap" appears, When you click ok,it prints the report. Is there something we can do to correct this?? Any input would be appreciated. Thanks ...

Cannot get started in Visio 2007
Hello, I am unable to open a new document or anything. When i click on "New" all the menu options are greyed out and i cannot select anything. sounds like an unregistered copy, al "stimperz" <stimperz@discussions.microsoft.com> wrote in message news:47ECDED7-15BB-4488-A3CE-AE8D5C6C85D6@microsoft.com... > Hello, > I am unable to open a new document or anything. When i click on "New" all > the menu options are greyed out and i cannot select anything. > ------=_NextPart_0001_F0A9A5B3 Content-Type: text/plain Content-Transfer-Encoding: 7bit I...

Using Word in outlook starts typing in different locations
As I start typing in an email reply or even drfting a new email, I will sometimes be typing away when all of a sudden I look at the screen and find that the cursa has moved and I am typing in a different part of the message, this also happens with word 2003. It is very frustrating and if anyone could give me some assistance with problem I would be eternally grateful. Turn off your microphone. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted...

How to get a CTime from a string
Hi all I have a CString that has a time formated like this "01/30/2004 01:41:53 PM". Can anyone tell me an easy way to create a CTime object from this string without needing to parse it manually. Thanks If you don't mind using the COleDateTime object instead, it has a ParseDateTime method. Ali R. "msnews.microsoft.com" <mbm_1975@hotmail.com> wrote in message news:eRCANWb8DHA.1936@TK2MSFTNGP12.phx.gbl... > Hi all > I have a CString that has a time formated like this "01/30/2004 01:41:53 > PM". Can anyone tell me an easy way to create a CTime...

Legitimate email getting deleted!!
My boss receives many emails from the office manager. Suddenly, in the last week, all emails from her have gone into the deleted items folder. We have looked everywhere for a rule that might be doing this. He has a junk mail rule and an adult senders rule, and no others. He adds names to these as he gets them but we searched each list and her name is not there. So I created a rule that says when items are received form her, stop processing any more rules, and put this at the top. Email is still going to the deleted items folder. What is going on here? How can I fix this for him? Thanks, ...

Excel, how do I get ALT F C to work the same as ALT F Enter C ?
The above is an example, but it aplies to any menu. Before, if I pressed say, ALT F, the drop down menu would appear and I could press, say, C and get to the submenu. Now I have to press Enter, before the C, which is a bother. Thanks. On my Windows 2000 version 5.00.2195 with Excel '97 and Excel 2003 the Alt F C still works. What version software / Excel are you using? -- Bryan Hessey ------------------------------------------------------------------------ Bryan Hessey's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=21059 View this thread: http://www....

How to get data from Beta to BCM Trial
I have the trial and now have lost all my BCM data. I was getting the following until I deleted the BCM portion that was being loaded. Outlook 2007 trial small business. On start up I get three error messages that data entered in the beta cannot be opened in the contact mgr. So I say ok to all and Outlook opens. When I click on the business contact mgr folder under all mail items I get the above error message. Help? How do I get all my data back? I also can't get anyone to respond so I am putting this everywhere! ...

How to get a cell to error if the wrong figue is entered
I have a worksheet that is a quote form for quoting on bricks. Bricks are only avaliable in lots of 66. So if my sales people are giving a quote say for 3000 bricks this would not be possiable because they only come in lots of 66, the figue they would have to enter would be 3036. I was wondering if there is a way to get the cell to show an error if the figue entered dose not work with multiables of 66. Thanks Why not just have them enter the number of lots instead? Then have your formula multiply it by 66. ************ Anne Troy www.OfficeArticles.com "Eintsein_mc2" <simonmerk...

I deleted a tab in OneNote, is there some way to get it back?!
I'm using Microsoft Office OneNote 2007. I had a tab that I wanted to delete, but I accidently deleted the wrong one! I didn't notice until several minutes later after messing around in O.N. some more. After I freaked out, I click the undo button. A lot. But eventually the button went gray and wouldn't let me undo any more things. And still* didn't get my tab back. Is there some way to get it back?! Pleassseeeee help! EggHeadCafe - Software Developer Portal of Choice Essential ASP.NET With Examples in C# http://www.eggheadcafe.com/tutorials/aspnet/8f709566-1d04-...

Upgraded from Exchange 2003 standard to enterprise now I get strange logs
I just upgraded my exchange 2003 server to enterprise. The install went fine and everythign seems to work however I now have information events in my application log. the message is as follows. Event Type: Information Event Source: Ci Event Category: CI Service Event ID: 4109 Date: 11/2/2006 Time: 7:29:43 AM User: N/A Computer: FRASERV_MAIL Description: Master merge was started on c:\system volume information\catalog.wci because more than 20000 documents have changed since the last master merge. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp...

get popups/alerts when i created a table from a query
I created a table using a query. Now whenever I run the query I get popups/alerts informing me that I am deleting the table and another informing me that I am added the data records to the table. The query works fine. But I can do without the popups/alerts. This database will be available for to all users. How can I avoid these popups/alerts as well as the other users. Thank you. On Thu, 14 Feb 2008 14:00:01 -0800, Ms937j <Ms937j@discussions.microsoft.com> wrote: >I created a table using a query. Now whenever I run the query I get >popups/alerts informing me that I a...

ADO connect mysql
Dear Sirs, I want to use mysql as database,and work on the datas through ADO in the excel. so I get exchange the datas with Excel and mysql. This is best way for my works I can imagine this moment. Please help me to provide me code how to establish connection from Excel to mysql. thanks advancely. Best regards http://forums.mysql.com/read.php?10,100302 Tim "Li Jianyong" <LiJianyong@discussions.microsoft.com> wrote in message news:56BC5ABE-CBB6-4F76-B956-32153ECDB5AD@microsoft.com... > Dear Sirs, > > I want to use mysql as database,and wo...

getting email address of To property in Outlook Inbox and From property in Outlook Outbox
I have a requirement to get the email address to whom emails in the Outlook inbox was sent as well as the From address for emails in the Outlook outbox. I have only looked into making this happen with the Inbox scenario thus far. Here are the problems I am running into. I first tried getting the information by for eaching through the Recipients property. But the Address property is always null. Then if I check the To property I don't get the email address but just the full name of the person that owns the email address. The ReceivedByName property gives me the same thing as the To prop...

How to get money online ?
I Recomended 2 Link 1) http://isabelmarco.com/?r=afis 2) http://www.buxout.com/?r=Afis Join now and see the proof ...

how can i get expart in ms office
"ttttttttttt" <ttttttttttt@discussions.microsoft.com> wrote in message news:5391A499-A69A-4F16-A4DC-8C9FF57C5F90@microsoft.com... <nothing> This is a completely ambiguous question. Do you mean you want to find an expert in Office or that you want to become an expert in Office. For the former, Google would be a good tool to help search for one. For the later, read published books and use the various apps extensively to discover how they work. -- Brian Tillman [MVP-Outlook] If you wish to become an expert, in addition to what Mr. Tillman has advi...

How to get the parent process ID of a process, thanks
Hi All, How to get the parent process ID of a process, thanks Beside using performanceCounter i found that we can use lpfCreateToolhelp32Snapshot, but i cannot convert it to win32 version correctly, what is the problem?Thanks [DllImport("Psapi.dll")] private static extern IntPtr lpfCreateToolhelp32Snapshot(int value, int value1); [DllImport("Kernel32.dll")] private static extern bool lpfProcess32First(IntPtr pointer, out PROCESSENTRY32 value); [DllImport("Kernel32.dll")] private static extern ...

how to get absolute XPath
Hi, I'm trying to get the absolute xpath to a node in DOM (XmlDocument). I know I can build it by warlking the tree recursively, but I'm wondering if there is an API in DOM or in XPathNavigator that allows me to get the absolute path for a given node? Thanks, --Ader. gonzalez wrote: > I'm trying to get the absolute xpath to a node in DOM (XmlDocument). I know > I can build it by warlking the tree recursively, but I'm wondering if there > is an API in DOM or in XPathNavigator that allows me to get the absolute > path for a given node? The DOM in .NET (Xml...

getting next column and filename
Hi; I need to copy a range of data Range("B28").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy then I paste this in a new spreadsheet. (this is no problem) Now my question.. 1. I need to write the filename at the top of the column that the data came from. 2. Select the next column so that I loop (to paste the next files data into..) this process will repeat about 600 times.. Thank you for your time and efforts.. Sam, Only one problem - you cannot use 600 columns on one sheet. But you can put the data onto separate sheets: the code below will pu...

Excel getting Error
My excel file was working fine until yesterday.suddenly when i try to open the file it giving the error message "file format is not valid " But i can open the file in Ms WORD. AND I CAN SEE THE DATA. SO WHAT I DID I COPIED ALL THE DATA AND PASTED IN NEW EXCEL SHEET. I CAN GET THE DATA BUT NOT THE FORUMLA..?? I HAVE LOT OF FORMULA IN EXCEL SHEET.. CAN ANYONE HELP ME HOW TO RECOVER IT? HOW TO OPEN THE EXCEL WHICH IS GIVING THE ABOVE ERROR. MSWord allows you to open .xls files. The bad news is that if you save that file in MSWord (as an MSWord document with .xls as the extensi...

Why didn't I get Publisher when I installed Microsoft Office 2000.
I was just wondering why I haven't got Microsoft Publisher on my computer? I have Windows XP and Microsoft Office 2000 so I don't see why I shouldn't have it. Is there any way you can install it? Or is it really expensive to get? Office 2000 did not automatically come with Publisher. If you have a second disk, Publisher will be on it. Having Publisher is dependent on what version Office you purchased. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "cheeky_angel85" <cheeky_angel85@discussions.microsoft.co...

ADO
Hi, Can I use ActiveX Data Objects(ADO) with any ODBC compliant database to access data? Hi Rishi; Yes you can do that easily, by choosing ODBC connection in the Ado Control properties... Monther "Rishi Shah" <rishi.shah@patni.com> wrote in message news:758be1e.0307232203.1478afee@posting.google.com... > Hi, > > Can I use ActiveX Data Objects(ADO) with any ODBC compliant database to access data? ...

Getting system date
Hello, I was wondering if there was any MFC function which I can call that can get the year, can get the month, and can get the day from the system. Sincerely, James Simpson Straightway Technologies How about: // Convert CTime to FILETIME CTime time(CTime::GetCurrentTime()); SYSTEMTIME timeDest; time.GetAsSystemTime(timeDest); FILETIME fileTime; ::SystemTimeToFileTime(&timeDest, &fileTime); -johnny"James Simpson" <anonymous@discussions.microsoft.com> wrote in message news:03f701c3cba4$6d63fbd0$a301280a@phx.gbl... > Hello, > I was wondering if there was...

How to get a certain cursor shape
Hi all, Excel 2007 I was trying to go through the steps of summarizing table data, and part of the instructions said "move the pointer over the upper-left corner of the column header until it becomes an arrow that is at about at a 5:00 angle. Then click once to select the table's data range, and again to select the entire table. This is used with the DSUM with the database criteria. It is also used with the DCOUNTA function. I would truly like to know at what point this arrow can be achieved as I have tried numerous times and all I can get is the straight down arrow, which d...