自日期以来的日历天数

时间:2019-08-28 14:29:51

标签: postgresql datetime

给出以下sqlfiddle:http://www.sqlfiddle.com/#!17/f483a/2/0

create table test (
    start_date date
);
insert into test values ('2019/01/01');


select 
start_date, 
age(now()::date,start_date) as date_diff
from test;

哪个生成以下输出:

date_diff | 0 years 7 mons 27 days 0 hours 0 mins 0.00 secs

我该如何生成正确的日历天数 239 days 不使用自定义功能

1 个答案:

答案 0 :(得分:2)

请勿使用年龄功能。 import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( backgroundColor: Colors.blue, body: MoveContainer(), ), ); } } class MoveContainer extends StatefulWidget { @override _MoveContainerState createState() => _MoveContainerState(); } class _MoveContainerState extends State<MoveContainer> { Offset offset = Offset.zero; final double height = 200; final double width = 200; @override Widget build(BuildContext context) { return GestureDetector( onPanStart: (details) { RenderBox getBox = context.findRenderObject(); setState(() { offset = getBox.localToGlobal(details.globalPosition); }); }, child: Stack( children: <Widget>[ AnimatedPositioned( duration: Duration(milliseconds: 300), top: offset.dy - (height / 2), left: offset.dx - (width / 2), child: Container( color: Colors.cyan, height: height, width: width, child: Text("hello "), ), ), ], ), ); } } 中的Subtractingdate产生一个整数。 date返回一个now(),因此您需要改用timestamp

current_date