繁体   English   中英

如何在sqlite android中获取最大日期时间?

[英]How to get a Maximum DateTime in sqlite android?

这是Android开发的新工具,我怀疑我是否已将datetime字段保存为sqlite中的文本,如何在这些记录中获取最大datetime,如何实现此目的,我知道可以通过我尝试过的Max()查询来实现,没有在这里得到结果,让我发布到目前为止我已经尝试过的内容:

这是Sqlite查询:

 public String DateTime(){
        String str="";
        Cursor cursor = db.query(CustomerModel.CustomerTable , new String [] {"MAX(" + CustomerModel.Customer_LastMofiedFlag +")"}, null, null, null, null, null);
        if(cursor.moveToFirst()) { // to move the cursor to first record
            int index = cursor.getColumnIndex(CustomerModel.Customer_LastMofiedFlag);
            str = cursor.getString(index);
        }  mcontext.getContentResolver().notifyChange(DB_Timetracker, null);
        return str;
    }

是否有可能以文本格式获取最大日期时间,同时将日期时间格式保存在yyyy-MM-dd HH:mm:ss中,我该如何实现呢!

也许您可以尝试将其保存为长格式?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM