• ADO读写DateTime方式


    // 读取日期
    var	= m_pResultSet->GetCollect(_variant_t("Birth_Time"));
    	
    DATE			dt		= var.date;
    COleDateTime	da		= COleDateTime(dt);
    CString			strData	= da.Format(_T("%Y-%m-%d"));
    m_GridList.SetItemText(m_nRow, m_nColumn, strData);
    
    
    // 写入日期
    COleDateTime	oleDate = COleDateTime::GetCurrentTime();
    CString			strDate = oleDate.Format(_T("%Y-%m-%d %H:%M:%S"));
    
    m_pBorrowRS->Fields->GetItem(_variant_t("Borrow_Date"))->PutValue(_variant_t(strDate));	
    m_GridList.SetItemText(m_nRow, m_nColumn, strDate);
    
    或:
    COleDateTime	oleDate = COleDateTime::GetCurrentTime();
    
    _variant_t	vtDate;
    vtDate.vt	= VT_DATE;
    vtDate		= oleDate.Format(_T("%Y-%m-%d %H:%M:%S"));
    
    m_pBorrowRS->Fields->GetItem(_variant_t("Borrow_Date"))->PutValue(vtDate);
    m_GridList.SetItemText(m_nRow, 3, (LPCTSTR)_bstr_t(vtDate));
    

     COleDateTime::GetCurrentTime()        var.date                

                                        \                     /                 

                                          \                 /                  

                                             \            /                   

                                    COleDateTime  oleDate;                                            

                                            /              \                  

                                          /                  \                

                                        /                      \   

                  var = oleDate.Format(...)     strDate = oleDate.Format(...)

  • 相关阅读:
    H5实现的时钟
    Hystrix 熔断机制原理
    Redis模块化基本介绍
    Redis Pipeline原理分析
    Redis事务原理分析
    Java NIO原理分析
    Java Reference 源码分析
    JDK AtomicInteger 源码分析
    Java 包装类笔记
    Spring Cache 笔记
  • 原文地址:https://www.cnblogs.com/sura/p/2501183.html
Copyright © 2020-2023  润新知